package com.hunt.controller;

import com.hunt.model.dto.PageInfo;
import com.hunt.service.SystemService;
import com.hunt.service.UserPaymentInfoService;
import com.hunt.util.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author nine
 * @date 2024/3/14/014
 * @Description
 */

@Api(value = "用户购买信息管理模块")
@Controller
@RequestMapping("userpaymentinfo")
public class UserPaymentInfoController {

    private static final Logger log = LoggerFactory.getLogger(UserPaymentInfoController.class);

    @Autowired
    private UserPaymentInfoService userPaymentInfoService;
    @Autowired
    private SystemService systemService;
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    /**
     *
     * @return
     */
    @ApiOperation(value = "跳转至用户购买信息管理模块", httpMethod = "GET", produces = "text/html")
    @RequiresPermissions("paymentinfo:list")
    @RequestMapping(value = "userpaymentinfo", method = RequestMethod.GET)
    public String userpaymentinfo() {
        return "system/userpaymentinfo";
    }


    /**
     * @param page      起始页码
     * @param rows      分页大小
     * @param sort      排序字段
     * @param order     排序规则
     * @param username  购买用户姓名
     * @param phone      购买用户的电话
     * @param accountTimeBegin   用户开户时间-起始
     * @param accountTimesEnd    用户开户时间-截至
     * @param paymentTimeBegin  支付时间-起始
     * @param paymentTimeEnd    支付时间-截至
     * @return
     */
    @ApiOperation(value = "查询用户购买信息列表", httpMethod = "GET", produces = "application/json", response = PageInfo.class)
    @ResponseBody
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public PageInfo list(@RequestParam(defaultValue = "1") int page,
                         @RequestParam(defaultValue = "30") int rows,
                         @RequestParam(defaultValue = "zhName") String sort,
                         @RequestParam(defaultValue = "asc") String order,
                         @RequestParam(defaultValue = "", required = false) String username,
                         @RequestParam(defaultValue = "", required = false) String phone,
                         @RequestParam(defaultValue = "", required = false) String accountTimeBegin,
                         @RequestParam(defaultValue = "", required = false) String accountTimesEnd,
                         @RequestParam(defaultValue = "", required = false) String paymentTimeBegin,
                         @RequestParam(defaultValue = "", required = false) String paymentTimeEnd){
        PageInfo pageInfo = userPaymentInfoService.selectPage(page, rows, StringUtil.camelToUnderline(sort), order, username, phone, accountTimeBegin,
                                                        accountTimesEnd,paymentTimeBegin,paymentTimeEnd);
        return pageInfo;
    }

}
